/**
 * 组合模式 
 */


/**
 * Component
 *
 * 扫描对象文件
 */
class Component {}

Component.prototype.add = (...args) => {}
Component.prototype.remove = (...args) => {}
Component.prototype.display = (...args) => {}

class Leaf extends Component {
  constructor() {
    super()
    this.name = name
  }

  add(...args) {
    console.log('不能添加叶子')  
  }

  remove(...args) {
    console.log('不能去除叶子')
  }

  display(...args) {
    console.log('打印深度')  
  }

}

class Composite extends Component {
  constructor() {
    super()
    this.children = []
  }

  add(...args) {
   this.children.push(args) 
  }

  remove(...args) {
    this.children.pop(args)
  }
  
  display(...args) {
    console.log('打印深度')
  }
   
}

class CompositePattern {
  constructor() {
    this.root = new Composite()
    this.root.add(new Leaf("Leaf A"))
    this.root.add(new Leaf("Leaf B"))

    this.comp = new Composite()
    this.comp.add(new Leaf("Leaf XA"))
    this.comp.add(new Leaf("Leaf XB"))
    this.comp.add(this.comp)

  }
}
